
#include "CxCircularBuffer.h"

using namespace DataRevPart;

CxCircularBuffer::CxCircularBuffer(size_t size):CxImageBuffer(size),m_curpt(0)
{
}

CxCircularBuffer::~CxCircularBuffer()
{
}


void CxCircularBuffer::Push(const Mat &img )
{
	try
	{
		{
			_Mutex::scoped_lock lock(m_mu);	
			
			Push_(img);
		}
	}
	//threadÒì³£´¦Àí£¬ÍË³ö
	catch(boost::thread_interrupted &)
	{
		throw ;
	}
}

Mat		CxCircularBuffer::Pop()
{
	Mat   _tmp;
	try
	{
		{
			//¾Ö²¿Ëø
			_Mutex::scoped_lock lock(m_mu);
			_tmp=Pop_();

			//ÌáÐÑbufferµ÷ÓÃÕß¿ÉÒÔ¶ÁÈ¡
		}
		return	_tmp;
	}
	//Òì³£´¦ÀíÍË³ö
	catch(const boost::lock_error &)
	{
		throw ;
	}
	catch(const boost::thread_interrupted &)
	{
		throw ;
	}
}


void	CxCircularBuffer::Push_(const Mat& _img)
{
	CX_NO_IMP;
}


Mat		CxCircularBuffer::Pop_()
{
	CX_NO_IMP;
	Mat mat;
	return mat;
}
